package com.tq.util;

import com.tq.R;

import android.R.integer;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.view.Gravity;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class ShowUtil {

	private Dialog dlg;
	private Context context;
 
	private TextView tv_pgdlg_msg,tv_pgdlg_title;
	private ImageView iv_pgdlg;
	private Dialog pg_dlg;
	public ShowUtil(Context context) {
		super();
		this.context = context;
		
	}
	
	public Dialog createDlg(int style,int dlgview,boolean isTouchCancel,int gravity)
	{
		dlg=new Dialog(context,style);
		dlg.setContentView(dlgview);
		dlg.setCanceledOnTouchOutside(isTouchCancel);
		return dlg;
	}
	
	
	
	public void showPgDlg(String title,String msg,int pgicon)
	{
		pg_dlg=createDlg(R.style.progress_dialog, R.layout.progress_dialog, false, Gravity.TOP);
		iv_pgdlg=(ImageView)dlg.findViewById(R.id.iv_load);
		
		
		tv_pgdlg_title=(TextView)dlg.findViewById(R.id.tv_load_title);
		tv_pgdlg_title.setCompoundDrawablesWithIntrinsicBounds(pgicon, 0, 0, 0);
		tv_pgdlg_title.setText(title);
		
		tv_pgdlg_msg=(TextView)dlg.findViewById(R.id.tv_load_msg);
		tv_pgdlg_msg.setText(msg);
		
		Animation animation =AnimationUtils.loadAnimation(context, R.anim.progress_dialog);
		iv_pgdlg.setAnimation(animation);
		
		pg_dlg.show();
		
	}
	
	public void closePgDlg()
	{
		if(pg_dlg.isShowing())
		{
			pg_dlg.dismiss();
		}
		
	}
	
	
	
	public void showToast(int flag,String msg)
	{
		
		if(flag==0)
		{
			Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
		}
		else {
			Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
		}
		
		
	}
	
	
}
